/**
 * Created by bing on 2020/3/14.
 */
package com.wxb.mybatis;

import com.wxb.mybatis.beans.Dict;
import com.wxb.mybatis.dao.DictMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * describe:
 *
 * @author : wxbing
 * @date : 2020-03-14
 */
public class HelloTest {

	public static void main(String[] args) {
		//加载我们的mybatis配置文件
		String resource = "mybatis-configuration.xml";
		try {
			//主要目的：得到session对象
			InputStream ins = Resources.getResourceAsStream(resource);
			SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(ins);
			System.out.println(sessionFactory.getConfiguration().getLocalCacheScope());
			System.out.println(sessionFactory.getConfiguration().isCacheEnabled());
			SqlSession session = sessionFactory.openSession(true);
			// List<String> lists = session.selectList("com.wxb.mybatis.dao.DictMapper.selectByKey", null);
			DictMapper dictMapper = session.getMapper(DictMapper.class);
			Dict five = dictMapper.selectById(5);
			Dict five2 = dictMapper.selectById(5);
			System.out.println(five.toString());
		} catch (IOException e) {
			System.out.println("testMember方9法中");
			e.printStackTrace();
		}
	}

}
